<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>投保预览</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<link rel="stylesheet" href="css/jquery.datetimepicker.css" type="text/css" />
<link rel="stylesheet" href="css/poshytip/tip-yellowsimple/tip-yellowsimple.css" type="text/css" />
<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
<script src="js/common.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript" src="js/poshytip/jquery.poshytip.js"></script>
<style type="text/css">
.setp{margin-bottom: 20px}
.mainMid {
    align-text:center;
    margin-right:40px;
    margin-left:40px;
    margin-top:20px;
    padding: 60px 98px;
    border: 2px solid #ececec;
    border-top: 3px solid #C1C1C1;''
}
.hide_h{display:none;}
.list-order {
    background-color: #fff;
    border-top: 1px solid #e6e6e6;
    margin-bottom: 8px;
}

ol, ul {
    list-style: none;
}

.li-st {
    border-bottom: 1px solid #e6e6e6;
    padding: 10px;
    overflow: hidden;
    color: #333;
}

li {
    display: list-item;
    text-align: -webkit-match-parent;
}

.li-st .fore1, .li-st .fore2, .li-st .fore3, .li-st .fore4, .li-st .fore5
    {
    margin-right: 15px;
    float: left;
}

.ftx-01, a.flk-01:link, a.flk-01:visited, .flk-01 a:link, .flk-01 a:visited
    {
    color: #f63;
}

.m, .mt, .mc {
    overflow: hidden;
    zoom: 1;
}

.msop .mt .icon-succ02 {
    margin-left: -60px;
    float: left;
}

.o-mb {
    margin-top:20px;
    font-size: 12px;
    height: 35px;
    line-height: 35px;
}

.f-c-f63 {
    color: #f63;
    float: right;
}

#pay-msg {
    padding: 15px;
}

.error {
    background-position: 96px 48px;
}

.wrong {
    background-position: 48px 48px;
}

/*清浮动  */

.clearfix:before,.clearfix:after {
    content: "";
    display: block;
    clear: both;
}

.clearfix {
      zoom: 1;
}
</style>
<script type="text/javascript">
$(function(){
    init();
});
function init() {
    
}
//电子保单下载
function downLoadPol(eUrl){
    window.open(eUrl);
}
function downLoadNotice(){
    $.message("error", "没生成对应的电子保单！");
}
function repeatPay(stagNo,pricelessType){
	var effdates=$(" .effdate");
    var beginTime="";
    //取出最小的日期
    for(var i=0;i<effdates.length;i++){
        
        if(i>0){
            if(compareTo(beginTime,effdates[i].value)){
                beginTime=effdates[i].value;
            }
        }else{
            beginTime=effdates[i].value;
        }
        
    }
    var now = new Date;
    now.setMinutes (now.getMinutes () + 10);
    var nowDate=now.getFullYear()+"-"+(((now.getMonth()+1)<10)?("0"+(now.getMonth()+1)):(now.getMonth()+1))+"-"+comple_Zero(now.getDate())+" "+comple_Zero(now.getHours())+":"+comple_Zero(now.getMinutes())+":00";
    
    if(compareTo(nowDate,beginTime)){
        $.dialog2({
            width: 400,
            top:40,
            height:120,
            title: "支付提示",
            ok:"确定",
            cancel:"取消",
            content: "<div style='margin:20px'>当前时间已晚于规定支付时间，请重新投保！</div>",
            onClose:function(){
                
            },
            onCancel:function(){
                
            },
            onOk: function() {
            }
        });
        return;
    }
    $.dialog2({
        width: 400,
        top:40,
        title: "支付提示",
        ok:"支付遇到问题",
        cancel:"支付完成",
        content: "<div style='margin:20px'>支付完成前，请不要关闭此支付验证窗口。为了您的保单及时生效，请在今天23:59之前完成支付，支付完成点击以下按钮继续操作。</div>",
        onClose:function(){
        },
        onCancel:function(){
            window.location.href = "<%=path%>/pay/resultNlife?stagNo="+encodeURIComponent(stagNo)+"&pricelessType="+pricelessType+"&type=1";
        },
        onOk: function() {
            window.location.href = "<%=path%>/pay/resultNlife?stagNo="+encodeURIComponent(stagNo)+"&pricelessType="+pricelessType+"&type=1";
        }
    });
    window.open("<%=path%>/pay/newpaymentmethod?stagNo="+encodeURIComponent(stagNo))+"&type=1";
}
function comple_Zero(s){
    return (((s+1)<10)?("0"+(s)):(s));
}
function compareTo(beginTime,endTime){
    var beginTimes = beginTime.substring(0,10).split('-');  
    var endTimes   =  endTime.substring(0,10).split('-');  
      
    beginTime = beginTimes[1]+'-'+beginTimes[2]+'-'+beginTimes[0]+' '+beginTime.substring(10,19);  
    endTime    = endTimes[1]+'-'+endTimes[2]+'-'+endTimes[0]+' '+endTime.substring(10,19);   
    var a =(Date.parse(endTime)-Date.parse(beginTime))/3600/1000;
    if(a<0){
        return true;
    }else if (a>0){
        return false;
    }else if (a==0){  
        return true;
    }  
 }
//重新编辑
function editAgain(cardNo,stagNo){
    var url = "<%=path%>/activatedCard/single/add?cardNo="+cardNo+"&stagNo="+encodeURIComponent(stagNo)+"&editFlag=edit";
    window.location.href = url;
}
//重新投保
function repeatActive(stagNo){
    $.dialog2({
        width: 400,
        top:40,
        height:120,
        title: "重新投保提示",
        content: "<div style='margin:20px'>确定要删除投保信息，重新投保吗？</div>",
        onClose:function(){
            
        },
        onCancel:function(){
            
        },
        onOk: function() {
            deleteBatchInfos(stagNo);
        }
    });
}
function deleteBatchInfos(stagNo){
    $.openLoading();
    $.ajax({
        url : "<%=path%>/activatedCard/repeatActive",
           type : 'POST',
           async : true,
           dataType : 'json',
           data : {
               stagNo :stagNo
           },
           success : function(obj) {
               $.closeLoading();
               if ("success" == obj.result) {
                   $.message("success",obj.message); 
                   window.location.href = "<%=path%>/activatedCard/index";
               }else if ("error" == obj.result) {
                   $.message("error",obj.message); 
               } else{
                   $.message("error","系统异常，请联系管理员"); 
               }
           }
       });
}

//重新出单
function repeatSend(appNo,pricelessType,stagNo){
    $.openLoading();
    $.ajax({
         url : "<%=path%>/pay/paymentConfirmAgain",
            type : 'POST',
            async : true,
            dataType : 'json',
            data : {
                appNo : appNo,
                stagNo :stagNo
            },
            success : function(obj) {
                $.closeLoading();
                if ("success" == obj.result) {
                    window.location.href = "<%=path%>/pay/resultNlife?stagNo="+encodeURIComponent(stagNo)+"&pricelessType="+pricelessType+"&type=1";
                }else if ("error" == obj.result) {
                	$.message("error",obj.message); 
                } else{
                    $.message("error","系统异常，请联系管理员"); 
                }
            }
        });
    }
</script>
</head>
<body>
    <div class="current">
        <table class="current_table_1">
            <tbody>
                <tr class="f2">
                    <td><img src="./images/current_1.jpg"></td>
                    <td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                        <span style="color: #136bab;">激活卡管理 <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>激活卡激活
                            <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>激活结果
                    </span></td>
                    <td><img src="./images/current_3.jpg"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="mainMid">
        <div class="setp"><jsp:include page="../include/stepScroll.jsp"/></div>
        <div id="resultDiv">
           <h3 class="succ hide_h">感谢您，保单投保成功！
               <span style="float: right" class="f-c-f63">元</span>
               <span style="float: right" class="f-c-f63">${facadeTempPolicy.amount }</span>
               <span style="float: right; font-size: 12px">含税保费合计：</span>
           </h3>
           <h3 class="fail hide_h">保单出单失败，请重试！
               <span style="float: right" class="f-c-f63">元</span>
               <span style="float: right" class="f-c-f63">${facadeTempPolicy.amount }</span>
               <span style="float: right; font-size: 12px">含税保费合计：</span>
           </h3>
           <h3 class="payWait hide_h">保单暂未支付，请支付！
               <span style="float: right" class="f-c-f63">元</span>
               <span style="float: right" class="f-c-f63">${facadeTempPolicy.amount }</span>
               <span style="float: right; font-size: 12px">含税保费合计：</span>
           </h3>
           <h3 class="err hide_h">异常状态，请重试！
               <span style="float: right" class="f-c-f63">元</span>
               <span style="float: right" class="f-c-f63">${facadeTempPolicy.amount }</span>
               <span style="float: right; font-size: 12px">含税保费合计：</span>
           </h3>
           <br>
        <script type="text/javascript">
        var indexVal;
        var isSeeMoneyStr = ('${pricelessType}'=='0' ? '1' : '2'); // 1 非见费；2 见费
        if('${facadeTempPolicy.status}'=='02'){
            indexVal = (isSeeMoneyStr == '2' ? 5 : 4); 
            stepConObj.stepContentFlag=isSeeMoneyStr;//1非见费和2见费标识
            stepConObj.curStepIndex=indexVal;//当前已完成索引位置
            $(".succ").css('display','block');
        }else if('${facadeTempPolicy.status}'=='14'||'${facadeTempPolicy.status}'=='12'){
            indexVal = (isSeeMoneyStr == '2' ? 4 : 3); 
            stepConObj.stepContentFlag=isSeeMoneyStr;//1非见费和2见费标识
            stepConObj.curStepIndex=indexVal;//当前已完成索引位置
            $(".fail").css('display','block');
        }else if('${facadeTempPolicy.status}'=='11'||'${facadeTempPolicy.status}'=='13'){
            stepConObj.stepContentFlag=2;//1非见费和2见费标识
            stepConObj.curStepIndex=4;//当前已完成索引位置
            $(".payWait").css('display','block');
        }else{
            indexVal = (isSeeMoneyStr == '2' ? 4 : 3); 
            stepConObj.stepContentFlag=isSeeMoneyStr;//1非见费和2见费标识
            stepConObj.curStepIndex=indexVal;//当前已完成索引位置
            $(".err").css('display','block');
        }
        stepControl(stepConObj);
        </script>
           <div class="mc clearfix" id="success_detail">
              <ul class="list-order">
                  <c:forEach var="facadeAppForm" items="${facadeTempPolicy.facadeAppForms}">
                      <input class='effdate' type="hidden" value="${facadeAppForm.stringEffDate}">
                      <li class="li-st">
                          <div class="fore1">
                              <c:choose>
                                  <c:when test="${facadeAppForm.polNo!=null}">
                                                                                                                 保单号：${facadeAppForm.polNo}
                                  </c:when>
                                  <c:otherwise>
                                                                                                               投保单号:${facadeAppForm.appNo}
                                  </c:otherwise>
                              </c:choose>
                          </div>
                          <div class="fore2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;含税保费：
                               <strong class="ftx-01">${facadeAppForm.totPremamt}元 </strong>
                               &nbsp;&nbsp;&nbsp;不含税保费：${facadeAppForm.premNotax}元
                               &nbsp;&nbsp;&nbsp;增值税额：${facadeAppForm.premVat}元
                          </div>
                          
                          <div class="fore3" >
                                                                                              出单状态：
                              <c:choose>
                                  <c:when test="${facadeTempPolicy.status=='02'||facadeTempPolicy.status=='12'||facadeTempPolicy.status=='14'}">
                                      <c:choose>
                                          <c:when test="${facadeAppForm.polNo!=null}">
                                              <span>已出单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                              <c:if test="${facadeAppForm.isEpolicy eq 'Y'}">
                                                  <c:choose>
                                                      <c:when test="${facadeAppForm.eUrl!=null and facadeAppForm.eUrl!=''}">
                                                               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input  type="button" onclick="downLoadPol('${facadeAppForm.eUrl}')" value="电子保单下载"> 
                                                            <div style="margin-left:150px;">
                                                               <img  alt="" width="150px;"  title="手机扫码下载电子保单" height="150px;"  id="dzbd" src="" >
                                                            </div>
                                                          <script type="text/javascript">
                                                          $("#dzbd").attr("src","<%=path %>/activatedCard/generateQRcode?url="+encodeURIComponent('${facadeAppForm.eUrl}'));
                                                          </script> 
                                                      </c:when>
                                                      <c:otherwise>
                                                          &nbsp;&nbsp;<input type="button" onclick='downLoadNotice();' value="电子保单下载">
                                                      </c:otherwise>
                                                  </c:choose>
                                              </c:if>
                                              
                                          </c:when>
                                          <c:otherwise>
                                              <span>未出单</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                              <a href="javascript:;" onclick="repeatSend('${facadeAppForm.app_No}','${pricelessType}','${stag_No}')">[重新出单]</a>
                                          </c:otherwise>
                                      </c:choose>
                                  </c:when>
                                  <c:when test="${facadeTempPolicy.status=='11'||facadeTempPolicy.status=='13'}">
                                      <span>未支付</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                      <a href="javascript:;" onclick="repeatPay('${stag_No}','${pricelessType}')">[重新支付]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                      <a href="javascript:;" onclick="repeatActive('${stag_No}');">[重新投保]</a>
                                  </c:when>
                                  <c:otherwise>
                                      <span style="color: #F45821;">异常</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                      <a href="javascript:editAgain('${cardNo}','${stag_No}');">[编  辑]</a>
                                  </c:otherwise>
                              </c:choose>
                          </div>
                      </li>
                  </c:forEach>
              </ul>
          </div>
          <div class="o-mb">
             <h5 class="d-tips" style="font-weight: normal; color: #333; font-size: 14px; margin-bottom: 10px;">
                 <strong> 重要提醒： </strong> 平台及销售商不会以 
                 <strong class="ftx-01">保单异常、系统升级 </strong> 等为由，要求您点击任何链接进行退款操作。
             </h5>
                                          完成投保后，您可以：<a href="<%=path%>/activatedCard/index" style="color:blue;font-size:18px;">继续投保</a>
         </div>
     </div>
     </div>
</body>
</html>